//
//  FriendGroup.m
//  05 -- QQ 好友列表展示
//
//  Created by Rainy Zou on 15/11/25.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "FriendGroup.h"
#import "Friend.h"

@implementation FriendGroup

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if(self ==[self init])
    {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}


+ (instancetype)friendGroupWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];
}

+ (NSArray *)friendGroupList
{
    NSString *path = [[NSBundle mainBundle]pathForResource:@"friends" ofType:@"plist"];
    NSArray *array = [NSArray arrayWithContentsOfFile:path];
    
    NSMutableArray *groupArray = [NSMutableArray array];
    for (NSDictionary *dict in array) {
        FriendGroup *group = [self friendGroupWithDict:dict];
        NSMutableArray *tempArray = [NSMutableArray array];
        for (NSDictionary *dic in group.friends) {
            Friend *friend = [Friend friendWithDict:dic];
            [tempArray addObject:friend];
        }
        group.friends = tempArray;
        [groupArray addObject:group];
    }
    
    return groupArray;
    
}

@end
